package com.eco.generator;


import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

public enum TypeMapper {

    DATA_1 (String.class,"varchar(255)"),
    DATA_2 (Integer.class,"int"),
    DATA_3 (Long.class,"bigint"),
    DATA_4 (Float.class,"float"),
    DATA_5 (Double.class,"double"),
    DATA_6 (BigDecimal .class,"decimal(13,2)"),
    DATA_7 (LocalDateTime .class,"datetime"),
    DATA_8 (LocalDate .class,"date"),
    DATA_9 (Date .class,"datetime"),
    ;

    public Class clazz;
    public String sqlType;


    TypeMapper(Class clazz, String sqlType) {
        this.clazz = clazz;
        this.sqlType = sqlType;
    }


    public static String getSqlType(Class<?> clazz) {
        for (TypeMapper value : values()) {
            if (value.clazz == clazz) {
                return value.sqlType;
            }
        }
        return null;
    }
}
